package cn.wanho.service.impl;

import cn.wanho.dao.CmsTrueFalseMapper;
import cn.wanho.dto.CmsTrueFalse;
import cn.wanho.service.CmsTrueFalseService;
import cn.wanho.rvo.myeasyexcel.CmsTrueFalseData;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CmsTrueFalseServiceImpl implements CmsTrueFalseService {
    @Resource
    private CmsTrueFalseMapper cmsTrueFalseMapper;
    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void insert(List<CmsTrueFalseData> list,Integer id) {
            for (CmsTrueFalseData data : list) {
                CmsTrueFalse cq=new CmsTrueFalse();
                cq.setSort(data.getSort());
                cq.setContent(data.getContent());
                cq.setAnswer(data.getAnswer());
                cq.setValue(data.getValue());
                cmsTrueFalseMapper.insert(cq);
                System.out.println("数据插入数据库成功！！"+cq);
                redisTemplate.opsForSet().add("wanhocms:paper:TrueFalse:"+ id,cq);
            }
        }

}
